package com.onesports.intelligent.k12.polarlight.controller.wx.coach;

import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.market.EducationEvaluationRecordAddDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.market.UploadMienDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.wx.CoachEvaluateDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.ClassWxDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.CoachClassPageVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.wx.CoachEvaluateVO;
import com.onesports.intelligent.k12.polarlight.service.evaluation.EducationEvaluationRecordService;
import com.onesports.intelligent.k12.polarlight.service.grade.ClassInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author FPH
 * @since 2022年7月15日23:09:37
 */
@RestController
@Api(tags = "教练端-班级")
@RequiredArgsConstructor
@RequestMapping(ApiPathConstants.WX_CLASS_STUDENT)
@PreAuthorize("hasAuthority('MINI_APP_COACH')")
public class CoachClassController {

    private final ClassInfoService classInfoService;

    private final EducationEvaluationRecordService educationEvaluationRecordService;
    @GetMapping("/page")
    @ApiOperation(value = "班级列表分页")
    public ResponseEntity<List<CoachClassPageVO>> getPage(){
        return ResultUtil.success(classInfoService.getCoachClassList());
    }

    @GetMapping("/mien")
    @ApiOperation(value = "班级风采")
    public ResponseEntity<List<CoachClassPageVO>> getMien(String classId){
        return ResultUtil.success(classInfoService.getMienByClass(classId));
    }

    @GetMapping("detail")
    @ApiOperation("获取班级详情")
    public ResponseEntity<ClassWxDetailVO> getWxClassDetail(String classId){
        return ResultUtil.success(classInfoService.getWxClassDetail(classId,true)) ;
    }

    @PostMapping("evaluation")
    @ApiOperation("教学评价")
    public ResponseEntity<String> addEvaluation(@RequestBody @Valid EducationEvaluationRecordAddDTO dto){
        return educationEvaluationRecordService.addEvaluation(dto)
                ?ResultUtil.success("操作成功"):ResultUtil.success("操作失败");
    }

    @PostMapping("/uploadMien")
    @ApiOperation("上传素材")
    public ResponseEntity<String> upload(@Valid @RequestBody UploadMienDTO dto){
        return classInfoService.uploadMien(dto)
                ?ResultUtil.success("操作成功"):ResultUtil.success("操作失败");
    }

    @GetMapping("get-evaluate")
    @ApiOperation("获取教练对学员的评价")
    public ResponseEntity<CoachEvaluateVO> getEvaluate(@Valid CoachEvaluateDTO dto){
        return ResultUtil.success(classInfoService.getEvaluate(dto)) ;
    }
}
